package com.cskaoyan.day6;

import java.util.Arrays;

public class MergeArray {
    public static void main(String[] args) {
        int[] arr1 = {1, 2, 3};
        int[] arr2 = {2, 2, 2};
        System.out.println(Arrays.toString(mergeArray(arr1, arr2)));
    }

    private static int[] mergeArray(int[] arr1, int[] arr2) {
        int newLen = arr1.length + arr2.length;
        int[] newArr = new int[newLen];
        int index = 0;
        for (int i = 0; i < arr1.length; i++) {
            newArr[index++] = arr1[i];
        }

        for (int i = 0; i < arr2.length; i++) {
            newArr[index++] = arr2[i];
        }
        return newArr;
    }
}
